//
//  FPAuthenticationHeaderView.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/1/22.
//

#import "FPAuthenticationHeaderView.h"

@implementation FPAuthenticationHeaderView

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    self.backgroundColor = UIColor.clearColor;
    
    self.view1.clipsToBounds = YES;
//    self.view1.layer.cornerRadius = 8.f;
    [UIView setCornerForView:self.view1 withRadius:8.f bounds:CGRectMake(0.f, 0.f, SCREEN_WIDTH - 32.f, 325.f) corners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)];
    
    self.manualBackView.clipsToBounds = YES;
    [UIView setCornerForView:self.manualBackView withRadius:8.f bounds:CGRectMake(0.f, 0.f, SCREEN_WIDTH - 32.f, 190.f) corners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)];
    
    self.manualBackView.hidden = YES;
    
    self.infoBackView.clipsToBounds = YES;
    self.infoBackView.layer.cornerRadius = 8.f;
    
    self.frontFailureLab.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:.5f];
    self.frontFailureLab.textColor = UIColor.whiteColor;
    
    self.backFailureLab.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:.5f];
    self.backFailureLab.textColor = UIColor.whiteColor;
    
    self.backFailureLab.hidden = YES;
    self.frontFailureLab.hidden = YES;
    
    NSString *text = @"本人实名认证 激活额度";
    NSRange range = [text rangeOfString:@"激活额度"];
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text];
    [NSString stringToAttribute:attr color:MAIN_BLUE_COLOR range:range];
    self.titleLab.attributedText = attr;
    
    self.infoLineView.backgroundColor = [[UIColor hexColor:@"#DEDEDE"] colorWithAlphaComponent:.5f];
    self.lineView1.backgroundColor = [[UIColor hexColor:@"#DEDEDE"] colorWithAlphaComponent:.5f];
    self.maualLineView.backgroundColor = [[UIColor hexColor:@"#DEDEDE"] colorWithAlphaComponent:.5f];
    
    self.infoTipLab1.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.infoTipLab1.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.infoTipLab1.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.nameLab.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.idNumberLab.textColor = [UIColor hexColor:@"#3A3A3A"];

    
//    self.headerView.clipsToBounds = YES;
//    self.headerView.layer.cornerRadius = 8.f;
    self.headerLab.textColor = [UIColor hexColor:@"#6A6A6A"];
    self.headerView.backgroundColor = UIColor.clearColor;

//    self.headerView.backgroundColor = [[UIColor hexColor:@"#0D6FFF"]colorWithAlphaComponent:.05f];
    
    self.backView1.clipsToBounds = YES;
    self.backView1.layer.cornerRadius = 4.f;
    self.backView1.backgroundColor = [UIColor hexColor:@"#FAFAFA"];
    
    self.backView2.clipsToBounds = YES;
    self.backView2.layer.cornerRadius = 4.f;
    self.backView2.backgroundColor = [UIColor hexColor:@"#FAFAFA"];
    
    self.backView3.clipsToBounds = YES;
    self.backView3.layer.cornerRadius = 4.f;
    self.backView3.backgroundColor = [UIColor hexColor:@"#FAFAFA"];
    
    self.backView4.clipsToBounds = YES;
    self.backView4.layer.cornerRadius = 4.f;
    self.backView4.backgroundColor = [UIColor hexColor:@"#FAFAFA"];
    
    NSString *text1 = @"没带身份证？点此继续申请";
    NSRange range1 = [text1 rangeOfString:@"点此继续申请"];
    NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:text1];
    [NSString stringToAttribute:attr1 color:MAIN_BLUE_COLOR range:range1];
    self.tipLabContinueApply.attributedText = attr1;
    
    self.alipayView.clipsToBounds = YES;
    self.alipayView.layer.cornerRadius = 4.f;
    self.alipayView.backgroundColor = [UIColor hexColor:@"#EFF6FF"];
    
    
    NSString *text2 = @"没带身份证？点此继续申请";
    NSRange range2 = [text2 rangeOfString:@"点此继续申请"];
    NSMutableAttributedString *attr2 = [[NSMutableAttributedString alloc] initWithString:text2];
    [NSString stringToAttribute:attr2 color:MAIN_BLUE_COLOR range:range2];
    self.manualTipLabContinueApply.attributedText = attr2;
    
    self.manualAlipayView.clipsToBounds = YES;
    self.manualAlipayView.layer.cornerRadius = 4.f;
    self.manualAlipayView.backgroundColor = [UIColor hexColor:@"#EFF6FF"];
    
    self.maualTitleLab.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.maualNameLab.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.maualNumberLab.textColor = [UIColor hexColor:@"#3A3A3A"];
    
    [self.leftBtn setTitle:@"携带身份证" forState:(UIControlStateNormal)];
    [self.rightBtn setTitle:@"未携带身份证" forState:(UIControlStateNormal)];
    [self.leftBtn setTitleColor:[UIColor hexColor:@"#000000"] forState:(UIControlStateNormal)];
    [self.rightBtn setTitleColor:[UIColor hexColor:@"#9A9A9A"] forState:(UIControlStateNormal)];
    
    self.pointView1.clipsToBounds = YES;
    self.pointView1.layer.cornerRadius = 2.f;
    self.pointView1.backgroundColor = MAIN_BLUE_COLOR;
    
    self.pointView2.clipsToBounds = YES;
    self.pointView2.layer.cornerRadius = 2.f;
    self.pointView2.backgroundColor = MAIN_BLUE_COLOR;
    
    self.pointView2.hidden = YES;
}

- (void)switchAutoInput:(BOOL)isAuto {
    
    if (isAuto) {
        
        self.manualBackView.hidden = YES;
        self.view1.hidden = NO;
        self.infoBackView.hidden = NO;
        self.switchImgView.image = IMG(@"bg_switch_input_left");
        
        self.leftBtn.titleLabel.font = BFONT(16.f);
        self.rightBtn.titleLabel.font = FONT(14.f);
        
        [self.leftBtn setTitleColor:[UIColor hexColor:@"#000000"] forState:(UIControlStateNormal)];
        [self.rightBtn setTitleColor:[UIColor hexColor:@"#9A9A9A"] forState:(UIControlStateNormal)];
        
        self.pointView1.hidden = NO;
        self.pointView2.hidden = YES;
        
        [UIView animateWithDuration:.25f animations:^{
           
            [self.pointView1 setWidth:1.f];
            [self.pointView1 setCenterX:self.leftBtn.centerX];
        }];
        
        [UIView animateWithDuration:.25f animations:^{
           
            [self.pointView2 setWidth:24.f];
            [self.pointView2 setCenterX:self.rightBtn.centerX];
        }];
    }
    else {
        
        self.manualBackView.hidden = NO;
        self.view1.hidden = YES;
        self.infoBackView.hidden = YES;
        self.switchImgView.image = IMG(@"bg_switch_input_right");
        
        self.rightBtn.titleLabel.font = BFONT(16.f);
        self.leftBtn.titleLabel.font = FONT(14.f);
        
        [self.rightBtn setTitleColor:[UIColor hexColor:@"#000000"] forState:(UIControlStateNormal)];
        [self.leftBtn setTitleColor:[UIColor hexColor:@"#9A9A9A"] forState:(UIControlStateNormal)];
        
        self.pointView2.hidden = NO;
        self.pointView1.hidden = YES;
        
        [UIView animateWithDuration:.25f animations:^{
           
            [self.pointView2 setWidth:1.f];
            [self.pointView2 setCenterX:self.rightBtn.centerX];
        }];
        
        [UIView animateWithDuration:.25f animations:^{
           
            [self.pointView1 setWidth:24.f];
            [self.pointView1 setCenterX:self.leftBtn.centerX];
        }];
    }
}


@end
